/**************************************************//*!
 *
 * \file    dims.cpp
 * \brief   Algorithms about dimention manipulating
 *
 *  
 *
 * \author  Terence Wu
 * \date    Sep. 2009
 *
 ****************************************************/


#include "ifftgpu.h"
#include "dims.h"

using namespace std;

bool dims_split(list<Dim> &d, int idx, int factor)
{
    list<Dim>::iterator iter = d.begin();
    for (; idx>0; idx--) iter++;

    if (iter->n == factor) return true;

    if (!DIVIDES(factor, iter->n)) 
        return false;

    int s = iter->stride;
    iter->n = iter->n / factor;
    iter->stride  = factor * s;

    d.insert(iter, Dim(factor, s));

    return true;
}